<g:setProvider library="jquery"/>

<x:pager/><br/>
<table id="bookTable" class="tablesorter">
    <thead>
        <tr>

            <th/>
            <th>${message(code: 'book.name.label', default: 'Name')}</th>
            <th>${message(code: 'book.category.label', default: 'Category')}</th>
            <th>${message(code: 'book.description.label', default: 'Description')}</th>
            <th>${message(code: 'book.price.label', default: 'Price')}</th>
            <th>${message(code: 'book.extraFee.label', default: 'Extra Fee')}</th>
            <th>${message(code: 'book.stock.label', default: 'Stock')}</th>
            <th>${message(code: 'book.reserve.label', default: 'Reserve')}</th>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <th class="delete">Del</th>
              <th class="edit">Edit</th>
            </g:if>

        </tr>
    </thead>
    <tbody>
    <g:each in="${instanceList}" status="i" var="bookInstance">
        <tr>

            <td>${i+1}</td>
            <td class="show"><a href="#" title="Book Detail" rel="${request.contextPath}/book/show/${bookInstance.id}">${fieldValue(bean: bookInstance, field: "name")}</a></td>
            <td>${fieldValue(bean: bookInstance, field: "category")}</td>
            <td>${fieldValue(bean: bookInstance, field: "description")}</td>
            <td>${fieldValue(bean: bookInstance, field: "price")}</td>
            <td>${fieldValue(bean: bookInstance, field: "extraFee")}</td>
            <td>${fieldValue(bean: bookInstance, field: "stock")}</td>
            <td>${fieldValue(bean: bookInstance, field: "reserve")}</td>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <td class="delete"><g:remoteLink action="delete" update="content" before="if(!confirm('Are you sure?')) return false;" id="${bookInstance.id}"><span class="ui-icon ui-icon-trash"/></g:remoteLink></td>
              <td class="edit"><a href="#" title="Edit Book" rel="${request.contextPath}/book/edit/${bookInstance.id}"><span class="ui-icon ui-icon-pencil"/></a></td>
            </g:if>

        </tr>
    </g:each>
    </tbody>
</table>

<script type="text/javascript">
  setupAdminList({controller:'book', action:'list'});
</script>
